/**
 * @description 消息通知接口
 */

import request from '@/utils/request'
import logger from '@/utils/logger'

/**
 * @description 获取订单消息处理人列表
 */
export const fetchMessageNotificationList = async (data) => {
  try {
    return await request({
      url: '/dealer/pzDealerMsgd/getPzDealerMsgdListForOrder',
      method: 'post',
      data,
    })
  } catch (error) {
    logger.error('获取订单消息处理人列表失败', error)
    throw error
  }
}

/**
 * @description 保存订单消息处理人列表
 */
export const postMessageNotification = async (data) => {
  try {
    return await request({
      url: '/dealer/pzDealerMsgd/savePzDealerMsgdForOrder',
      method: 'post',
      data,
    })
  } catch (error) {
    logger.error('保存订单消息处理人失败', error)
    throw error
  }
}

/**
 * @description 删除订单消息处理人列表
 */
export const postDeleteMessageNotification = async (dealerMsgdId) => {
  try {
    return await request({
      url: `/dealer/pzDealerMsgd/deletePzDealerMsgdForOrderById?dealerMsgdId=${dealerMsgdId}`,
      method: 'post',
    })
  } catch (error) {
    logger.error('删除订单消息处理人失败', error)
    throw error
  }
}

/**
 * @description 消息类别列表
 */
export const fetchMessageTypeList = async () => {
  try {
    return await request({
      url: '/dealer/pzDealerMsgd/getPzDealerMsgmList',
      method: 'post',
    })
  } catch (error) {
    logger.error('获取消息类别列表失败', error)
    throw error
  }
}
